package com.banach.prema.executor;

import com.banach.prema.enums.SosStatus;
import com.banach.prema.repository.SosRepository;
import com.banach.prema.repository.dataobject.SosDO;
import com.ego.framework.dto.Response;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;

/**
 * @Author ajun
 * @Desc
 * @Date 2025/3/24 11:33
 */
@Component
public class SosEndExe {

    @Resource
    private SosRepository sosRepository;

    public Response end(Long sosId) {
        SosDO sosDO = sosRepository.getBaseMapper().selectById(sosId);
        sosDO.setEndTime(LocalDateTime.now());
        sosDO.setStatus(SosStatus.ENDED.getValue());
        return Response.build(sosRepository.update(sosDO));
    }
}
